import { SELECT } from '../actions/layout.action';

const initState = {
	navs: [
		{
			key: 'um',
			name: '用户管理',
			href: '/users',
			admin: '1',
			selected: false
		},
		{
			key: 'tpm',
			name: '分类管理',
			href: '/types',
			admin: '1',
			selected: false
		},
		{
			key: 'bm',
			name: '电子书管理',
			href: '/books',
			admin: '0',
			selected: true
		}
	]
}

function Layout(state=initState,action) {
	switch (action.type){
		case SELECT:
			state.navs.forEach(nav=>{
				nav.selected = action.key === nav.key;
			});
			return {...state};
		default :
			return state;
	}
}

export default Layout;